#这是测试用的部分，使用之前必须先导入config.tcl部分


#获取测试案例的数量
proc getTestNumber {} {
	global root
	rootIsSet
	set tests [$root selectNodes /config/tests]
	set count 0
	if {[catch {$tests childNodes} errMsg]} {
		puts "lacks tests tag"
		exit 1
	}
	foreach child [$tests childNodes] {
		incr count
	}
	return $count
}

#获取指定测试案例中的测试命令
#返回一个字典，字典中id对应要配置的设备顺序编号
#字典中commands对应该测试中的各条命令组成的一个链表
#字典中expect字段对应预期的测试结果
proc getTestCommands {id} {
	global root
	rootIsSet
	set tests [$root selectNodes /config/tests/test]
	set test [lindex $tests $id]
	if {[catch {set id [parseConfInfo $test id]} errMsg]} {
		puts "Tests lacks some configuration information"
		exit 1
	}
	set commandsNode [$test selectNodes commands]
	if {[catch {set expect [parseConfInfo $test expect]} errMsg]} {
		puts "Test $id lacks test/expect tag"
		exit 1
	}
	dict append testInfo id $id
	set commands {}
	if {[catch {$commandsNode childNodes} errMsg]} {
		puts "Test $id lacks test/commands tag"
		exit 1
	}
	foreach commandNode [$commandsNode childNodes] {
		set command [$commandNode selectNodes text()]
		set command [$command data]
		lappend commands $command
	}
	dict append testInfo commands $commands
	dict append testInfo expect $expect
	return $testInfo
}